package cn.myframe.controller.tb;

import java.util.Map;

import cn.myframe.utils.annotation.CheckSubmit;
import cn.myframe.utils.aop.AssociateData;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.myframe.controller.AbstractController;
import cn.myframe.controller.BaseController;
import cn.myframe.service.BaseService;
import cn.myframe.utils.core.R;
import cn.myframe.entity.tb.TbUserEntity;
import cn.myframe.service.tb.TbUserService;


/**
 * 
 * 
 * @author ynz
 * @email ynz@myframe.cn
 * @date 2018-12-08 14:58:47
 */
@RestController
@RequestMapping("/tb/tbuser")
public class TbUserController  extends AbstractController implements BaseController<TbUserEntity,BaseService<TbUserEntity>>{
	@Autowired
	private TbUserService tbUserService;
	
	/**
	 * 列表
	 */
	@ResponseBody
	@RequestMapping(value = "/list",method = {RequestMethod.GET})
	@RequiresPermissions("tbuser:list")
	public R list(@RequestParam Map<String, Object> params){
		return this.defaultList(params);
	}	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{userId}")
	@RequiresPermissions("tbuser:info")
	public R info(@PathVariable("userId") Long id){
		return this.defaultInfo(id,"tbUser");
	}
	
	/**
	 * 新增保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("tbuser:save")
	public R save(@RequestBody TbUserEntity tbUser){		
		return this.defaultSave(tbUser);
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("tbuser:delete")
	public R delete(@RequestBody Long[] ids){
		return this.defaultDelete(ids);
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")	
	@RequiresPermissions("tbuser:update")
	public R update(@RequestBody TbUserEntity tbUser){		
		return this.defaultUpdate(tbUser);
	}
	
	/**
	 * 复制
	 */
	@RequestMapping("/copy")
	public R copy(@RequestBody Long id){		
		return this.defaultCopy(id);
	}
	
   /**
    * 提交,审核
    */
	@RequestMapping("/audit")	
	@RequiresPermissions(value={"tbuser:submit","tbuser:auditpass","tbuser:auditnopass"},logical=Logical.OR)
	@CheckSubmit(AssociateData.USER_REGION)
	public R audit(@RequestBody Long[] ids ,@RequestParam Integer status){
		return this.defaultAudit(ids, status);
	}
	
   /**
	* 检验字段值重复
	*/
    @RequestMapping("/checkExist")
    @ResponseBody
    public String checkExist(String id,String value,String columnName){
        return this.defaultCheckExist(id, value, columnName);
    }
    
    public TbUserService getService(){
		return tbUserService;
	}
	
}
